import time

from selenium import webdriver
from selenium.webdriver.common.by import By

from base.base_page import BasePage


class PageRegister(BasePage):

    def __init__(self, driver: webdriver):
        super().__init__(driver)
        self.__phone=By.CSS_SELECTOR,"#username"
        self.__verify_code=By.CSS_SELECTOR,"input[placeholder='图像验证码']"
        self.__password=By.CSS_SELECTOR,"#password"
        self.__confirm_password=By.CSS_SELECTOR,"#password2"
        self.__recommend_phone=By.CSS_SELECTOR,"input[placeholder='请输入手机号码'][name='invite']"
        self.__register_button=By.CSS_SELECTOR,".regbtn.J_btn_agree"
        self.__register_success_text=By.CSS_SELECTOR,"a[title='退出']"
        self.__register_failure_text=By.CSS_SELECTOR,".layui-layer-content.layui-layer-padding"
   #输入手机号码
    def __input_phone(self,phone):
      self.ele_input(self.__phone,phone)
  #输入验证码
    def __input_verify_code(self,verify_code):
       self.ele_input(self.__verify_code,verify_code)
  #输入密码
    def __input_password(self,password):
       self.ele_input(self.__password,password)
  #输入确认密码
    def __input_confirm_password(self,confirm_password):
       self.ele_input(self.__confirm_password,confirm_password)

   #输入推荐人手机号
    def __input_recommend_phone(self,recommend_phone):
        self.ele_input(self.__recommend_phone,recommend_phone)

  #点击注册按钮
    def __click_register_button(self):
        self.ele_click(self.__register_button)


    def get_register_success_text(self):
        return self.get_ele_text(self.__register_success_text)

    def get_register_failure_text(self):
        return self.get_ele_text(self.__register_failure_text)
    #注册
    def register(self,phone, verify_code, password,confirm_password,recommend_phone):
        self.__input_phone(phone)
        self.__input_verify_code(verify_code)
        self.__input_password(password)
        self.__input_confirm_password(confirm_password)
        self.__input_recommend_phone(recommend_phone)
        self.__click_register_button()





